package com.xbao.core.util;

import java.math.BigDecimal;

/**
 * Created by qingshengzheng on 18/5/29.
 */
public class MathUtil {

    public static float floatTwoPoint(Float v) {

        int scale = 2;//设置位数
        int roundingMode = 4;//表示四舍五入，可以选择其他舍值方式，例如去尾，等等.
        BigDecimal bd = new BigDecimal((double) v);
        bd = bd.setScale(scale, roundingMode);
        v = bd.floatValue();
        return v;
    }


    public static float defautFloat(Float f) {
        if (f == null) return 0;
        else return f;
    }
    public static long defautLong(Long f) {
        if (f == null) return 0;
        else return f;
    }

}
